Trying to save file from Flash to PHP using $GLOBALS["HTTP_RAW_POST_DATA"]

Posted by jolyonruss on Stack Overflow See other posts from Stack Overflow or by jolyonruss
Published on 2010-04-11T21:09:38Z Indexed on 2010/04/11 21:13 UTC
Read the original article Hit count: 514

Filed under:
|
|
|
|

Let me start by saying PHP isn't my forte, I'm usually reluctant to try working with it because of problems exactly like this. The code works fine on my local machine under MAMP and on my server, but doesn't on the clients server :'(

So what am I trying to do, well - save an image from Flash onto the server, simple right?!

I'm using the method described on this site here: http://designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed-saving-images-from-flash/ but have made a small alteration so that instead of echoing the jpg causing the browser to download it locally, I do an fwrite and an fclose to save it to the server.

Here is my PHP:

    $imageFile = '../images/' . $_GET['name'];
    $imageHandle = fopen($imageFile, "w");

    fwrite($imageHandle, $jpg);

    fclose($imageHandle);
}

?>

I've dona a phpinfo() on my clients server and it's running 5.2.2 my host is running 5.2.11 I don't know if much can have changed in those 9 minor revisions?

I've also read another question on here which suggests making suer always_populate_raw_post_data is set to ON, but it's set to OFF on all of the server environments I've been testing in. I'm doing some XML saving using file_get_contents('php://input') which I've tried but failed to get working with images.

Any help would be gratefully received, I'm happy to post the AS3 as well but it's EXACTLY the same as example I've linked above and works locally. As far as I can tell the problem lies with the PHP.

Cheers.

© Stack Overflow or respective owner

Related posts about flash

Related posts about php